﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAOTAgency;

namespace TravelAgency
{
    public partial class WebFormDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int tourId = 0;
            if (Request.Params["TourID"] != null)
            {
                ButtonReservation.Visible = true;
                if (int.TryParse(Request.Params["TourID"].ToString(), out tourId))
                {
                    DivInfo.Visible = true;
                    RepeaterTourDetails.DataSource = DAO.GetTourById(tourId);
                    RepeaterTourDetails.DataBind();
                    List<string> facilities = DAO.GetHotelFacilitiesForTour(tourId);
                    if (facilities.Count == 0)
                    {
                        facilities.Add("no facilities in description");
                        HotelFacilities.DataSource = facilities;
                        HotelFacilities.DataBind();                        
                    }
                    else
                    {
                        HotelFacilities.DataSource = facilities;
                        HotelFacilities.DataBind();                        
                    }
                }
            }
            else
            {
                DivInfo.Visible = false;
                ButtonReservation.Visible = false;
            }
        }

        protected void ButtonReservation_Click(object sender, EventArgs e)
        {
            int tourId = int.Parse(Request.Params["TourID"]);
            Response.Redirect("WebFormReservation.aspx?TourID=" + tourId);
        }
    }
}